<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;

use Mail;

use Storage;

class MailController extends Controller
{
    // 发送邮件
    public function send(){
    	$name = "习泽";
    	// $imgPath = "http://www.canvas.com/images/favicon.png";
         
    	/*$image = Storage::get('placeholder.png');
    	$flag = Mail::send(['emails.test', 'emails.text'], ['name'=>$name, 'image'=>$image], function ($message){
    		$to = "1341219953@qq.com";
    		$message -> to($to) -> subject('测试邮件');
    		$attachment = storage_path('app/files/test.txt');
    		$message -> attach($attachment, ['as'=>'有一个测试文档.txt']);
    	});*/

    	// $flag = Mail::raw('文档测试邮件，哈哈哈', function($message){
    	// 	$to = '1341219953@qq.com';
    	// 	$message -> to($to) -> subject('Laravel文档邮件测试');
    	// 	$attachment = storage_path('app/files/test.txt');
    	// 	$message -> attach($attachment, ['as'=>'测试文档丫丫.txt']);
    	// });
         
    	if($flag){
    		echo '发送邮件成功，请查收';
    		throw new Exception();
    	}else{
    		echo '发送邮件失败，请重试';
    	}
    }
}
